home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.5 Applications 1998 June
/
SGI IRIX 6.5 Applications 1998 June.iso
/
dist
/
netwr_client.idb
/
var
/
spool
/
lp
/
model
/
nwpsinterface.z
/
nwpsinterface
Wrap
Text File
|
1998-05-06
|
4KB
|
206 lines
#!/bin/sh
#
# lp interface for generic PostScript printers, NetWare client interface
#
# $Revision: 1.1 $
# $Date: 1997/01/22 02:16:38 $
#
# Info for administration tools:
#
#
NAME=
PRINTER=
ZONE=
USER=
PASSWD=
TYPE=PostScript
exec 2>> log
#logfile=/var/spool/lp/log # lp spooler error log file
#exec 2>> $LOGFILE
# Change the following to set up defaults
GTMPDIR=/var/tmp
#BANNER=1
BANNER=0
# Whether pages come out of the printer face up or face down.
FACEUP=0
# If pages come out face down, don't reverse page order for input text.
if [ $FACEUP = 0 ]
then
opts="$opts -U"
fi
LOGFILE=log
RAW=0
send=/usr/lib/print/lptops
#VERBOSE=1
VERBOSE=0
#
# Grab command line arguments
printer=`basename $0`
seqid=$1
name=$2
title="$3"
copies=$4
options="$5"
shift; shift; shift; shift; shift
files="$*"
if [ $PASSWD = "_" ]
then
nwlogin="/usr/etc/netware/nwlogin $ZONE $USER"
else
nwlogin="/usr/etc/netware/nwlogin $ZONE $USER $PASSWD"
fi
psf="/usr/etc/netware/nprint -queue $PRINTER -server $ZONE"
nwlogout="/usr/etc/netware/nwlogout $ZONE"
if [ -z "$title" ] ; then
title=`basename $1`
fi
if [ ! -w "$LOGFILE" ] ; then
disable -r"can't access log file $LOGFILE" $printer 1>/dev/console 2>&1
exit 1
fi
for j in $options
do case $j in
-verbose | verbose | -debug | debug) VERBOSE=1;;
-noverbose | noverbose) VERBOSE=0;;
-banner | banner) BANNER=1;;
-nobanner | nobanner | -h | h) BANNER=0;;
-raw | raw) RAW=1;;
-cooked | cooked) RAW=0;;
*) opts="$opts $j";;
esac
done
if [ $VERBOSE != 0 ]
then
echo $printer: $seqid $name "$title" Start - `date` >> $LOGFILE
fi
SetTrap()
#
# This routine sets up the proper trap command.
# When a job is cancelled, the spooler sends us a SIGTERM.
# We could also get a SIGHUP or a SIGINT, so we'll catch those.
#
# It removes temporary/intermediate files created while filtering.
{
trap '/bin/rm -f $GTMPDIR/b$seqid # CleanTempFiles
exit' 1 2 15 # catch SIGHUP, SIGINT, and SIGTERM
}
SetTrap # Set the cancellation trap
# Change this for prettier banners or different number of columns
x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
y="<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>"
if [ $BANNER != 0 ]
then
touch $GTMPDIR/b$seqid
echo "$x\n$x\n$x\n$x\n" >> $GTMPDIR/b$seqid
/usr/bin/banner "$name" >> $GTMPDIR/b$seqid
echo "\n" >> $GTMPDIR/b$seqid
user=`grep "^$name:" /etc/passwd | line | cut -d: -f5`
if [ "$user" = "" ]
then
user=`(ypmatch $name passwd | line | cut -d: -f5) 2> /dev/null`
fi
if [ -n "$user" ]
then
echo "User: $user\n" >> $GTMPDIR/b$seqid
else
echo "\n" >> $GTMPDIR/b$seqid
fi
echo "Request id: $seqid Printer: `basename $0`\n" >> $GTMPDIR/b$seqid
date >> $GTMPDIR/b$seqid
echo "\n" >> $GTMPDIR/b$seqid
if [ -n "$title" ]
then
/usr/bin/banner $title >> $GTMPDIR/b$seqid
fi
# echo "\014\c" >> $GTMPDIR/b$seqid
#Trailer on the banner page
echo "$x\n$x\n$x\n$x\n" >> $GTMPDIR/b$seqid
fi
if [ $BANNER != 0 -a $FACEUP != 1 ]
then
$send $GTMPDIR/b$seqid | $psf 2> /dev/null
echo "print banner" >> $LOGFILE
fi
i=1
while [ $i -le $copies ]
do
for file in $files
do
realfile="`/sbin/ls -l $file | /usr/bin/awk '{ print $11 }'`"
magic=`dd bs=1 count=2 if=$file 2> /dev/null`
if [ "$magic" = "%!" ]
then
$nwlogin
$psf $realfile
$nwlogout
else
isend=/usr/lib/print/pprint
# check to see if it is an image file
set -- `dd bs=1 count=2 < $file 2> /dev/null | od -h`
if [ "$2" = 01da -a -x $isend ]
then
$nwlogin
$isend $realfile | $psf
$nwlogout
else
magic=
magic="`/bin/file $file | /usr/bin/cut -d: -f2`"
case "$magic" in
*script* | *ascii* | *command* | *English* | *ext* | *iso8859* )
$nwlogin
$psf $realfile
$nwlogout;;
* )
temp="$printer: Unknown type of file(bad magic) $file skipped..."
echo $temp >> $LOGFILE
echo $temp >&2
exit 1 ;;
esac
fi
fi
done
i=`expr $i + 1`
done
if [ $BANNER != 0 -a $FACEUP != 0 ]
then
$send $GTMPDIR/b$seqid 2> /dev/null
fi
if [ $VERBOSE != 0 ]
then
echo $printer: $seqid End - `date` >> $LOGFILE
fi
if [ $BANNER != 0 ]
then
/bin/rm -f $GTMPDIR/b$seqid
fi
exit 0